package interfaceDemo.Computer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025/5/9
 * Time: 19:15
 */

public class Computer {
    public void open(){
        System.out.println("Computer open");
    }
    public void useUsb(IUsb iusb){
        iusb.openDevice();
        if (iusb instanceof KeyBoard){
            //向下转型
            KeyBoard keyBoard = (KeyBoard)iusb;
            keyBoard.input();
        }
        if (iusb instanceof Mouse){
            //向下转型
            Mouse mouse = (Mouse)iusb;
            mouse.click();
        }
        iusb.closeDevice();
    }
    public void close(){
        System.out.println("Computer close");
    }
}
